package com.fumin.util;


import java.io.*;
import java.util.Properties;

/**
 * 单例类，读取FTP路径
 * 
 * @author tongzw
 * @date 2011/10/16
 */
public class PropertiesUtil {


	private static PropertiesUtil propertiesUtil;

	private Properties props;

	private InputStream isp;

	private static String walletPath;
	private static String userDepth;

//	{
//		PropertiesUtil.getInstance();
//	}

	public static String getWalletPath() {
		return walletPath;
	}

	public static void setWalletPath(String walletPath) {
		PropertiesUtil.walletPath = walletPath;
	}

	public static String getUserDepth() {
		return userDepth;
	}

	public static void setUserDepth(String userDepth) {
		PropertiesUtil.userDepth = userDepth;
	}

	private PropertiesUtil(){
		props = new Properties();
		isp = PropertiesUtil.class.getClassLoader().getResourceAsStream("properties/sys.properties");
		try {
			props.load(new InputStreamReader(isp, "utf-8"));
		} catch (IOException e) {
			e.printStackTrace();
		}
		walletPath = props.getProperty("walletPath");
	}

	public String get(String arg) throws IOException {
		props.load(new InputStreamReader(isp, "utf-8"));
		return props.getProperty(arg);

	}

	/**
	 * 单例
	 * 
	 * @return
	 */
	public synchronized static PropertiesUtil getInstance() {

		if (propertiesUtil == null) {
			propertiesUtil = new PropertiesUtil();
		}
		return propertiesUtil;
	}



	public static void main(String[] args) {
		System.out.println(PropertiesUtil.getInstance().getWalletPath());
	}

}
